import fetch from 'utils/fetch';
//获取省列表
export function queryHadProvince(provinceId,curPage,pageSize) {
    const params = {
        provinceId
    };
    return fetch({
        url: '/sysArea/provinceQuery/'+curPage+'/'+pageSize,
        method: 'post',
        params
    });
}
// 查询市
export function queryHadCity(provinceId,cityId,curPage,pageSize) {
    const params = {
        provinceId,
        cityId
    };
    console.log('/sysArea/provinceQuery/'+curPage+'/'+pageSize,'000000');
    return fetch({
        url: '/sysArea/cityQuery/'+curPage+'/'+pageSize,
        method: 'post',
        params
    });
}
// 查询区
export function queryHadArea(provinceId,cityId,areaId,curPage,pageSize) {
    const params = {
        provinceId,
        cityId,
        areaId
    };
    return fetch({
        url: '/sysArea/areaQuery/'+curPage+'/'+pageSize,
        method: 'post',
        params
    });
}

// 添加省
export function addProvince(provinceName) {
    const data = {
        provinceName
    };
    return fetch({
        url: '/sysArea/addProvince',
        method: 'post',
        data
    });
}
// 更新省
export function updateProvince(provinceName,provinceId) {
    const data = {
        provinceName,
        provinceId
    };
    return fetch({
        url: '/sysArea/updateProvince',
        method: 'post',
        data
    });
}
// 批量删除省
export function deleteProvince(provinceIds) {
    const params = {
        provinceIds
    };
    return fetch({
        url: '/sysArea/deleteProvince',
        method: 'post',
        params
    });
}


// 批量删除市
export function deleteCity(cityIds) {
    const params = {
        cityIds
    };
    return fetch({
        url: '/sysArea/deleteCity',
        method: 'post',
        params
    });
}

// 添加市
export function addCity(cityName,provinceId) {
    const data = {
        cityName,
        provinceId
    };
    return fetch({
        url: '/sysArea/addCity',
        method: 'post',
        data
    });
}

// 更新市
export function updateCity(cityName,provinceId,cityId) {
    const params = {
        cityName,
        provinceId,
        cityId
    };
    return fetch({
        url: '/sysArea/updateCity',
        method: 'post',
        params
    });
}


// 批量删除区
export function deleteArea(areaIds) {
    const params = {
        areaIds
    };
    return fetch({
        url: '/sysArea/deleteArea',
        method: 'post',
        params
    });
}

// 添加区
export function addArea(areaName,cityId,provinceId) {
    const data = {
        areaName,
        cityId,
        provinceId
    };
    return fetch({
        url: '/sysArea/addArea',
        method: 'post',
        data
    });
}

// 更新区
export function updateArea(provinceId,areaName,areaId,cityId) {
    const data = {
        provinceId,
        areaName,
        areaId,
        cityId
    };
    return fetch({
        url: '/sysArea/updateArea',
        method: 'post',
        data
    });
}


// 获取字典表
export function queryAllDict(type,curPage,pageSize) {
    const params = {
        type
    };
    return fetch({
        url: '/sysdic/queryAllDict/'+curPage+'/'+pageSize,
        method: 'post',
        params
    });
}
//查询所有字典类型
export function allDictType(type) {
    const params = {
        type
    };
    return fetch({
        url: '/sysdic/allDictType',
        method: 'post',
        params
    });
}

//添加字典
export function addDict(desc,name) {
    const data = {
        desc,
        name
    };
    return fetch({
        url: '/sysdic/addDict',
        method: 'post',
        data
    });
}

//更新字典
export function updateDict(desc,name,id) {
    const data = {
        desc,
        name,
        id
    };
    return fetch({
        url: '/sysdic/updateDict',
        method: 'post',
        data
    });
}


//批量删字典
export function deleteDicts(ids) {
    const params = {
        ids
    };
    return fetch({
        url: '/sysdic/deleteDicts',
        method: 'post',
        params
    });
}


//获取敏感词列表
export function listSensitiveWords(sensitiveWord,curPage,pageSize) {
    const data = {
        sensitiveWord
    };
    return fetch({
        url: '/sensitivewords/listSensitiveWords/'+curPage+'/'+pageSize,
        method: 'post',                  
        data
    });
}


//删除敏感词
export function deteleSensitiveWords(pIds) {
    const data = {
        pIds
    };
    return fetch({
        url: '/sensitivewords/deteleSensitiveWords',
        method: 'post',
        data
    });
}


//添加敏感词
export function addSensitiveWords(sensitiveWord,replaceWord) {
    const data = {
        sensitiveWord,
        replaceWord
    };
    return fetch({
        url: '/sensitivewords/addSensitiveWords',
        method: 'post',
        data
    });
}

//更新敏感词
export function updateSensitiveWords(sensitiveWord,replaceWord,pId) {
    const data = {
        sensitiveWord,
        replaceWord,
        pId
    };
    return fetch({
        url: '/sensitivewords/updateSensitiveWords',
        method: 'post',
        data
    });
}


//批量导入敏感词
export function importSensitiveWord(filePath,fileName) {
    const data = {
        filePath,
        fileName
    };
    return fetch({
        url: '/sensitivewords/importSensitiveWord',
        method: 'post',
        data
    });
}

//获取验证码
export function sphonecode(phoneNumber) {
    const params = {
        phoneNumber
    };
    return fetch({
        url: '/phonecode/query',
        method: 'post',
        params
    });
}

// 权限系统单独的地址接口
// var authorAPI = process.env.NODE_ENV === 'production' ? 'http://test.auth.juziwl.cn' : 'http://192.168.0.82:8080/exue-authcenter-web';
// var authorAPI = 'http://test.auth.juziwl.cn';
// var authorAPI = process.env.NODE_ENV === 'production' ? 'http://api.auth.jzexueyun.com' : ( process.env.NODE_ENV === 'sit' ? 'http://test.auth.juziwl.cn': 'http://192.168.0.82:8080/exue-authcenter-web');
var authorAPI = process.env.AUTHOR_API;

// 1.	分页查询角色.（用于权限管理首页）
export function getPageSysRole(json) {
    let defaultData = {
        fSystemId: '2',
        instId: '0',
    };
    let data = Object.assign({}, defaultData, json);
    return fetch({
        url: authorAPI + '/authcenter/sysRole/pageSysRole',
        method: 'post',
        data
    });
}

//　2.	获得操作者拥有的系统菜单.（用于新增角色页面）
export function getListSysMenuByOperator(json) {
    const defaultData = {
        fSystemId: '2', // 系统ID
        instId:'0',  // 操作者所属机构ID
    };
    let data = Object.assign({}, defaultData, json);
    return fetch({
        url: authorAPI + '/authcenter/sysRole/listSysMenuByOperator',
        method: 'post',
        data
    })
}   

//3.	新增角色，并新增角色和菜单的关系
export function saveSysRole(json) {
    const defaultData = {
        fSystemId: '2',
        instId: '0',
    };
    let data = Object.assign({}, defaultData, json);
    return fetch({
        url: authorAPI + '/authcenter/sysRole/saveSysRole',
        method: 'post',
        data
    });
}

// 4.	获得角色，并获得角色拥有的菜单.（用于更新角色页面和角色详情页面）
export function getSysRole(pId) {
    const data = {
        pId // 角色ID
    }
    return fetch({
        url: authorAPI + '/authcenter/sysRole/getSysRole',
        method: 'post',
        data
    });
}

// 5.	更新角色，并更新角色和菜单的关系
export function updateSysRole(data) {
    
    return fetch({
        url: authorAPI + '/authcenter/sysRole/updateSysRole',
        method: 'post',
        data
    });
}

// 6.	删除非管理员角色 [{pId:'378598380722585600'}]
export function removeSysRole(data) {

    return fetch({
        url: authorAPI + '/authcenter/sysRole/removeSysRole',
        method: 'post',
        headers:{
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data
    });
}

// 7.	查询系统中的管理员以外的所有角色
export function getListNonAdminSysRole(data) {
    
    return fetch({
        url: authorAPI + '/authcenter/sysRole/listNonAdminSysRole',
        method: 'post',
        data
    });
}
// 8.	根据用户的角色类型，查询系统中的角色。
export function getListSysRoleByUserRoleType(json) {
    console.log(json);
    const defaultData = {
        fSystemId: '2',
        instId: '0'
    };
    let data = Object.assign({}, defaultData, json);
    return fetch({
        url: authorAPI + '/authcenter/sysRole/listSysRoleByUserRoleType',
        method: 'post',
        data
    });
}
//查询web项目的系统信息
export function listAllWebSystemInfo() {
    return fetch({
        url: authorAPI + '/authcenter/sysOperationLog/listAllWebSystemInfo',
        method: 'post',
    });
  }

  //分页查询系统运行日志
  export function pageSysOperationLog(data) {
    return fetch({
        url: authorAPI + '/authcenter/sysOperationLog/pageSysOperationLog',
        method: 'post',
        data
    });
  }


